<!-- 分页 -->
<template>
  <div class="demo-pagination-block">
    <el-pagination
      :small="small"
      :disabled="disabled"
      :background="background"
      :layout="layout"
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="pagesizes"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>
<script lang="ts" setup>
import { useTableStore } from "@/store/modules/table";
import { ref } from "vue";
const TableStore = useTableStore();
const prop = defineProps<{
  option: any;
}>();

const currentPage = ref(1);
const pageSize = ref(prop.option.pageSize);
const small = ref(prop.option.small);
const background = ref(prop.option.background);
const total = ref(prop.option.total);
const layout = ref(prop.option.layout);
const pagesizes = ref(prop.option.pagesizes);
const disabled = ref(false);

const handleSizeChange = (val: number) => {
  TableStore.pageSize = val;
  TableStore.tableRender = !TableStore.tableRender;
};
const handleCurrentChange = (val: number) => {
  TableStore.pageIndex = val;
  TableStore.tableRender = !TableStore.tableRender;
};
</script>

<style scoped>
.demo-pagination-block + .demo-pagination-block {
  margin-top: 10px;
}
.demo-pagination-block .demonstration {
  margin-bottom: 16px;
}
</style>
